function vi(){
	return(validate3()&&validate1());
}

function v(){
	return(validate()&&validate1());
}
function validate() {
	var sd = document.getElementById("startDate").value;
	var ed = document.getElementById("endDate").value;
	var tomatch = /^[0-9][0-9][0-9][0-9]-[0-2][0-9]-[0-3][0-9]$/;
	
	if(sd == null || sd == ""){
		alert("Please enter start date.");
		return false;
	}
	else if(tomatch.test(sd) == 0){
		alert("Please enter start date with the correct format. YYYY-MM-DD");
		return false;
	}
	if(ed!="null" && ed!="" && ed !="-"){
		if(tomatch.test(ed) == 0){
			alert("Please enter end date with the correct format. YYYY-MM-DD");
			return false;
		}
		else{
			var sy=sd.substr(0,4);
			var sm=sd.substr(5,2);
			var sdt=sd.substr(8,2);

			var ey=ed.substr(0,4);
			var em=ed.substr(5,2);
			var edt=ed.substr(8,2);

			var startDate = new Date(sy, sm, sdt); //Year, Month, Date
			var endDate = new Date(ey, em, edt); //Year, Month, Date
			if (startDate >= endDate) {

				alert("End date should always be greater than or equal to start date");
				return false; 
			}  
			else return true;
		}
	}
	return true;
}

function validate3() {
	var sd = document.getElementById("startDate").value;
	var ed = document.getElementById("endDate").value;
	if(sd==""){
		alert("Please select a start date.");
		return false;
	}
	else if(ed!="null" && ed!="" && ed !="-"){
		var sy=sd.substr(0,4);
		var sm=sd.substr(5,2);
		var sdt=sd.substr(8,2);

		var ey=ed.substr(0,4);
		var em=ed.substr(5,2);
		var edt=ed.substr(8,2);

		var startDate = new Date(sy, sm, sdt); //Year, Month, Date
		var endDate = new Date(ey, em, edt); //Year, Month, Date
		if (startDate >= endDate) {

			alert("End date should always be greater than or equal to start date");
			return false; 
		}  
		else return true;
	}
	else
		return true;
}
function validate1(){
	var warning ="";
	var warning = document.getElementById("warning");
	var status ="";
	var formatvalid= checkformat();

	var check = (formatvalid);
	if(!check){
		if(!formatvalid)
			status = "Please enter Market name in the correct format." +
			"<br> Leading character and ending character should be Alphanumeric." +
			" Length should be less than 100.";

		warning.innerHTML = status;
	}
	else{
		return true;
	}
	return false;
}

function checkformat(){  
	var tomatch = /^[a-zA-Z].+[a-zA-Z]$/;
	var market = document.getElementById("marketname").value;
	var lengtherror = (market.length > 100);
	var leadingerror = (tomatch.test(market) == 0)
	if(lengtherror || leadingerror){
		return false;
	}
	return true;
}